#pragma once
#include "defines.h"
#include <output/output.h>
#include <base/camera.h>
#include <string>
#include <vector>
#include <map>

class IO
{
public:
    static void SaveTrcToSrc(const std::vector<GeoPoint> &geo_points, const std::string &csv_file);
};

class GpsBuffer
{
public:
    GpsBuffer();
    ~GpsBuffer();
    void LoadDataFromCsv(const std::string& csv_file);
    bool ReadNext(GeoPoint& gps_point);
    void FeedBack(GeoPoint& gps_point);
    void Print(DbgFrame* dbg_frame);
private:
    std::vector<GeoPoint> gps_points_;
    std::vector<GeoPoint> remain_points_;
};

class DlFrameBuffer
{
public:
    DlFrameBuffer(const std::string& dl_lane_path, const std::string& dl_sign_path);
    ~DlFrameBuffer();
    bool ReadNext(const GeoPoint& gps_point, const Camera& camera, DlFrame& dl_frame);
protected:
    bool LoadLaneFromJson(const std::string& json_file_name, const Camera& camera, std::vector<DlLane>& dl_lanes);
    bool LoadSignFromJson(const std::string& json_file_name, const Camera& camera, std::vector<DlSign>& dl_signs);
    void RemoveOverlapSigns(std::vector<DlSign>& dl_signs);
private:
    std::map<std::string, DlFrame> dl_frames_;
    std::string dl_lane_path_;
    std::string dl_sign_path_;
};

class HDMapBuffer
{
public:
    HDMapBuffer()
    {}

    ~HDMapBuffer()
    {}

   hdmap_frame LoadMapDataByPostion(const GeoPoint& gps_point, double range);
};